#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int T = 0;
	scanf("%d", &T);
	while (T--)
	{
		char str1[1000] = "0";
		char str2[1000] = "0";
		scanf("%s %s", str1,str2);
		if (str1[0] == str2[0] || str1[0] - str2[0] == 32 || str2[0] - str1[0] == 32)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}